/** 3. 无重复字符的最长子串
 * @param {string} s
 * @return {number}
 */
var lengthOfLongestSubstring = function(s) {
    let left = 0, right = 0, res = 0;
    let window = {}
    while(right<s.length){
        let c = s[right];
        right++;
        window[c] = (window[c] || 0) + 1;
        while(window[c]>1){
            let d = s[left];
            left++;
            window[d] = window[d]-1;
        }
        res = Math.max(res, right-left);
    }
    return res;
};